Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce wiz_light integration for WiZ bulbs #35132

Closed
wants to merge 21 commits into from
Closed

Introduce wiz_light integration for WiZ bulbs #35132

wants to merge 21 commits into from

Conversation

sbidy
Copy link
Contributor

@sbidy sbidy commented May 3, 2020

Proposed change

A HA integration for WiZ Light bulbs (Phillips, SLV and more). The integration extents HA to communicate directly with this WiFi connected lights via async UDP calls. There is no Cloud or Web API needed for interaction with this lights.

The integration is designed async, including the UDP calls via pywizlight extension.

Supported Features:

  • Brightness
  • Color (RGB)
  • White Color Temperature
  • On/Off, Toggle
  • Effects
  • Setting a rhythm as a scene
  • Bulb feature detection

wiz_light GitHub // pywizlight

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml
light:
  - platform: wiz_light
    name: Name_Bulb_1
    host: 127.0.0.1
  - platform: wiz_light
    name: Name_Bulb_2
    host: 127.0.0.2

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@homeassistant
Copy link
Contributor

Hi @sbidy,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@kpsuperplane
Copy link

As a happy use of this integration, there’s an unfortunately incompatibility with the HASS homekit integration.

HASS Homekit was recently changed to send RGB values for color temperatures. The wiz bulbs, however, are extremely limited in brightness when provided with RGB values compared to Kelvins. This makes it impossible to set the bulbs to any reasonable brightness after selecting a color in the HASS homekit integration.

You can see this in behavior in the HASS UI as well - the RGB “white” is significantly dimmer than the Kelvin “white”

Please let me know if should be reporting this somewhere else, wasn’t sure where to put it because it involves the core itself

@sbidy
Copy link
Contributor Author

sbidy commented May 12, 2020

Thanks for the feedback on this. 👍
I wasn't aware that homekit now only works on RGB values.
And yes, if I select "white" (255,255,255) in the RGB color wheel it will be dimmer and also not the same color temperature as the "cold white" selected with the kelvin slider in the UI. In my opinion this is a normal behavior and is depending on the triggered LEDs (RGB to RGBWA).

I think there a two main points:

  1. The standard HASS UI (currently) doesn't provide the same color/temperature selection interfaces as in the home-kit UI. In this case there is a general mismatch between the user experiences and user interaction (in my opinion). Additionally you get a problem if you try to sync multiple different lights to one white value. I think this can be only done with a well defined "standard" like kelvin where the bulb are optimized against.
  2. To move from a kelvin/mired value to a RGB "color temperature" definition will be become a problem because most of the WiZ light doesn't provide RGB color capabilities. They have only a brightness and a color temperature feature. In this case the only possible solution is to remap the RGB values (coming form the homekit) to kelvin, which is technical possible. But if the color temperature will be changed in the HASS UI and not in the homekit, I will get a mired/kelvin value from the HASS and not a RGB(?).

In my opinion this can be a general problem from the HA core because there should be a standard for the color temperature definition (kelvin or mired or RGB). If this standard unit will become/is RGB I can change my code and integrate a RGB-to-Kelvin function. I'll prefer to stay with Kelvin because it is a well defined standard unit.

Maybe @frenck can give us/me some more details/insights about the Kelvin-or-RGB discussion. 😉

Thank you again - I'll update the documentation in the wiz_light with the issue by integrations with homekit. 😄

@michaeldavie
Copy link
Contributor

Thanks for putting this together! I'm testing it out and it seems to be working well, though the logs are showing an unhandled error:

ERROR (MainThread) [custom_components.wiz_light.light] Cannot evaluate temperature
Traceback (most recent call last):
  File "/config/custom_components/wiz_light/light.py", line 251, in update_temperature
    self._light.state.get_colortemp()
  File "/usr/src/homeassistant/homeassistant/util/color.py", line 515, in color_temperature_kelvin_to_mired
    return math.floor(1000000 / kelvin_temperature)
ZeroDivisionError: division by zero

Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @sbidy! Thanks for the PR!

This integration is communicating with a device, and thus need to be implemented with a configuration flow via the frontend.

See: https://github.com/home-assistant/architecture/blob/master/adr/0010-integration-configuration.md

Developer information can be found here: https://developers.home-assistant.io/docs/config_entries_config_flow_handler#defining-your-config-flow

We have a scaffolding tool available to help out with this transition: python3 -m script.scaffold integration

Thanks!

@sbidy
Copy link
Contributor Author

sbidy commented Jun 3, 2020

@frenck thanks for the feedback. I'll update the pull with the config flow version soon. This update will also include a unique device ID for each bulb.

@michaeldavie in this case you have a bulb which doesn't support this function. The integration tries to idetifiv the bulb and the available functions. In some cases the bulb reports a invalid or unknown device type. Can you pleas provide your bulb type, vendor and maybe the device ID? Please also look into the wiz_light repo here on GitHub for more info.

@michaeldavie
Copy link
Contributor

Thanks, I've opened sbidy/wiz_light#26 to track this issue.

@stale
Copy link

stale bot commented Jul 6, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jul 6, 2020
@meyerrj
Copy link
Contributor

meyerrj commented Jul 9, 2020

Any updates on this? I have a few WiZ bulbs and would love for this to move forward. :)

@stale stale bot removed the stale label Jul 9, 2020
@michaeldavie
Copy link
Contributor

I'm using the code from https://github.com/sbidy/wiz_light as a custom component and it's working quite well.

@meyerrj
Copy link
Contributor

meyerrj commented Jul 9, 2020

@michaeldavie thanks! I was able to get it installed as a custom component and it is working beautifully!

I look forward to this PR being accepted. 😁

@stale
Copy link

stale bot commented Aug 9, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Aug 9, 2020
@caesar1987sk
Copy link

I hope this component will be part of hassio. I am using it without any problem as custom component.

@stale stale bot removed the stale label Aug 9, 2020
@sbidy
Copy link
Contributor Author

sbidy commented Aug 13, 2020

I try to bring in the required ConfigFlow thing but currently I've not enough time for test and implementation. I'm looking forward to solve that dependency in the next weeks.

Contributions are wellcomen :-)

@stale
Copy link

stale bot commented Sep 12, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Sep 12, 2020
@stale stale bot closed this Sep 20, 2020
@meyerrj
Copy link
Contributor

meyerrj commented Oct 27, 2020

Looks like this was auto-closed... Hoping this gets re-opened and moves forward. :)

@splerman
Copy link

Love the four Color Hue br30s we already have. Bought one wiz color br30 to compare quality. Was pleasantly surprised that brightness and color are more similar than I expected given the price difference. Was about to pull the trigger on buying 40 more wiz color br30s, but got cold feet seeing this went stale. A status update would be great!!

@sbidy
Copy link
Contributor Author

sbidy commented Oct 28, 2020

Work in progress 😉
The main problem is to creat a working ConfigFlow. Overall the integration works for most of the bulbs. Check out my wiz_light reop!

@awgneo
Copy link

awgneo commented Oct 28, 2020

Thanks, @sbidy! I have the Philips Smart Wi-Fi LED light strip with WiZ with which I can help test.

@haivala
Copy link

haivala commented Dec 22, 2020

This is somthing I need too!
@sbidy any news on this?

@sbidy
Copy link
Contributor Author

sbidy commented Dec 25, 2020

The new pull is online - #44522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants